class Food {

    element : HTMLElement;

    constructor(){
        this.element = document.getElementById("food")!;
    }

    get X(){
        return this.element.offsetLeft;
    }

    get Y(){
        return this.element.offsetTop;
    }

    change(){
        // 生成一个随机的位置
        this.element.style.left = randomCoordinate();
        this.element.style.top = randomCoordinate();
    }

}

function randomCoordinate(){
    return Math.round(Math.random()*29)*10 + "px";
}

export default Food;